<!DOCTYPE html>












  


<html class="theme-next gemini use-motion" lang="Chinese">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.4.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.4.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.4.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.4.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '6.4.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="vsftpd是Linux下非常流行的ftp服务器，这次就是用这款软件在CentOS 7下搭建一个ftp服务器。 安装vsftpd检查是否安装vsftpd rpm -qa | grep vsftpd 如果没有安装，就使用yum安装，并且设置开机启动 yum install -y vsftpdsystemctl enable vsftpd 基于虚拟用户配置ftp服务器虚拟用户就是指只针对于ftp服务的">
<meta name="keywords" content="CentOS,FTP">
<meta property="og:type" content="article">
<meta property="og:title" content="CentOS 7 下安装ftp服务">
<meta property="og:url" content="http://blog.zhengzi.me/2016/02/22/centos-7-e4-b8-8b-e5-ae-89-e8-a3-85ftp-e6-9c-8d-e5-8a-a1/index.html">
<meta property="og:site_name" content="政子的博客">
<meta property="og:description" content="vsftpd是Linux下非常流行的ftp服务器，这次就是用这款软件在CentOS 7下搭建一个ftp服务器。 安装vsftpd检查是否安装vsftpd rpm -qa | grep vsftpd 如果没有安装，就使用yum安装，并且设置开机启动 yum install -y vsftpdsystemctl enable vsftpd 基于虚拟用户配置ftp服务器虚拟用户就是指只针对于ftp服务的">
<meta property="og:locale" content="Chinese">
<meta property="og:updated_time" content="2018-08-21T09:49:42.773Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="CentOS 7 下安装ftp服务">
<meta name="twitter:description" content="vsftpd是Linux下非常流行的ftp服务器，这次就是用这款软件在CentOS 7下搭建一个ftp服务器。 安装vsftpd检查是否安装vsftpd rpm -qa | grep vsftpd 如果没有安装，就使用yum安装，并且设置开机启动 yum install -y vsftpdsystemctl enable vsftpd 基于虚拟用户配置ftp服务器虚拟用户就是指只针对于ftp服务的">






  <link rel="canonical" href="http://blog.zhengzi.me/2016/02/22/centos-7-e4-b8-8b-e5-ae-89-e8-a3-85ftp-e6-9c-8d-e5-8a-a1/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>CentOS 7 下安装ftp服务 | 政子的博客</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="Chinese">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">政子的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">强迫症|学习者|伪文青</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="Toggle navigation bar">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />Home</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-about">
    <a href="/about/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-user"></i> <br />About</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />Tags</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />Archives</a>
  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://blog.zhengzi.me/2016/02/22/centos-7-e4-b8-8b-e5-ae-89-e8-a3-85ftp-e6-9c-8d-e5-8a-a1/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Jason Bian">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="政子的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">CentOS 7 下安装ftp服务
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              

              
                
              

              <time title="Created: 2016-02-22 12:05:24" itemprop="dateCreated datePublished" datetime="2016-02-22T12:05:24+08:00">2016-02-22</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">Edited on</span>
                
                <time title="Modified: 2018-08-21 17:49:42" itemprop="dateModified" datetime="2018-08-21T17:49:42+08:00">2018-08-21</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>vsftpd是Linux下非常流行的ftp服务器，这次就是用这款软件在CentOS 7下搭建一个ftp服务器。</p>
<h2 id="安装vsftpd"><a href="#安装vsftpd" class="headerlink" title="安装vsftpd"></a>安装vsftpd</h2><p>检查是否安装vsftpd</p>
<p>rpm -qa | grep vsftpd</p>
<p>如果没有安装，就使用yum安装，并且设置开机启动</p>
<p>yum install -y vsftpd<br>systemctl enable vsftpd</p>
<h2 id="基于虚拟用户配置ftp服务器"><a href="#基于虚拟用户配置ftp服务器" class="headerlink" title="基于虚拟用户配置ftp服务器"></a>基于虚拟用户配置ftp服务器</h2><p>虚拟用户就是指只针对于ftp服务的用户，这些用户并不是Linux管理，没有使用真实的帐户，只是通过映射到真实帐户和设置权限的目的。虚拟用户不能登录系统。</p>
<h3 id="打开配置文件并修改"><a href="#打开配置文件并修改" class="headerlink" title="打开配置文件并修改"></a>打开配置文件并修改</h3><p>vim /etc/vsftpd/vsftpd.conf</p>
<p>作如下修改</p>
<p>anonymous_enable=NO //设定不允许匿名访问<br>local_enable=YES //设定本地用户可以访问。注：如使用虚拟宿主用户，在该项目设定为NO的情况下所有虚拟用户将无法访问<br>chroot_list_enable=YES //使用户不能离开主目录<br>ascii_upload_enable=YES<br>ascii_download_enable=YES //设定支持ASCII模式的上传和下载功能<br>pam_service_name=vsftpd //PAM认证文件名。PAM将根据/etc/pam.d/vsftpd进行认证</p>
<p>并添加这些配置项</p>
<p>guest_enable=YES //设定启用虚拟用户功能<br>guest_username=ftp //指定虚拟用户的宿主用户，CentOS中已经有内置的ftp用户了<br>user_config_dir=/etc/vsftpd/vuser_conf //设定虚拟用户个人vsftp的CentOS FTP服务文件存放路径。存放虚拟用户个性的CentOS FTP服务文件(配置文件名=虚拟用户名）</p>
<h3 id="对虚拟用户进行认证"><a href="#对虚拟用户进行认证" class="headerlink" title="对虚拟用户进行认证"></a>对虚拟用户进行认证</h3><p>首先，安装Berkeley DB工具，如果找不到db_load就是没有安装这个包</p>
<p>yum install db4 db4-utils</p>
<p>接着，创建用户密码文本</p>
<p>vim /etc/vsftpd/vuser_passwd.txt</p>
<p>编辑内容例如：</p>
<p>test<br>123</p>
<p>注意奇行是用户名，偶行是密码，可以有多个用户名和密码，只需要遵循上面法则即可。 生成虚拟用户文件</p>
<p>db_load -T -t hash -f /etc/vsftpd/vuser_passwd.txt /etc/vsftpd/vuser_passwd.db</p>
<p>编辑认证文件/etc/pam.d/vsftpd，全部注释掉原来语句，再增加以下两句：</p>
<p>auth required pam_userdb.so db=/etc/vsftpd/vuser_passwd<br>account required pam_userdb.so db=/etc/vsftpd/vuser_passwd</p>
<p>注意：需要加在文件开头，或者注释掉之前的语句 最后，创建虚拟用户配置文件</p>
<p>mkdir /etc/vsftpd/vuser_conf/<br>vim /etc/vsftpd/vuser_conf/test  //文件名等于vuser_passwd.txt里面的账户名，否则下面设置无效</p>
<p>文件内容如下</p>
<p>local_root=/var/www/html  //虚拟用户根目录,根据实际情况修改<br>write_enable=YES  //可写<br>anon_umask=022 //掩码<br>anon_world_readable_only=NO<br>anon_upload_enable=YES<br>anon_mkdir_write_enable=YES<br>anon_other_write_enable=YES</p>
<h2 id="另参考"><a href="#另参考" class="headerlink" title="另参考"></a>另参考</h2><p><a href="http://www.osyunwei.com/archives/9006.html" target="_blank" rel="noopener">http://www.osyunwei.com/archives/9006.html</a> <a href="http://www.cnblogs.com/xiongpq/p/3384759.html" target="_blank" rel="noopener">http://www.cnblogs.com/xiongpq/p/3384759.html</a> <a href="http://os.51cto.com/art/201002/184610.htm" target="_blank" rel="noopener">http://os.51cto.com/art/201002/184610.htm</a></p>
<h2 id="有坑提示"><a href="#有坑提示" class="headerlink" title="有坑提示"></a>有坑提示</h2><p>在设置文件权限的时候，不能将ftp目录的权限设置为777，这样vsftp是禁止登陆的（但是错误提示不是权限设置有误而是密码错误），如果需要更高权限的操作，可以将该目录嵌套于另一个低权限的目录下面。</p>

      
    </div>

    

    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/CentOS/" rel="tag"># CentOS</a>
          
            <a href="/tags/FTP/" rel="tag"># FTP</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/02/22/ssh-e6-97-a0-e6-93-8d-e4-bd-9c-e8-87-aa-e5-8a-a8-e6-8e-89-e7-ba-bf-e8-a7-a3-e5-86-b3-e6-96-b9-e6-b3-95/" rel="next" title="SSH无操作自动掉线解决方法">
                <i class="fa fa-chevron-left"></i> SSH无操作自动掉线解决方法
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/02/22/centos-7-e4-b8-8b-e4-bd-bf-e7-94-a8iptables-e4-bb-a3-e6-9b-bffirewall-e9-98-b2-e7-81-ab-e5-a2-99/" rel="prev" title="CentOS 7下使用iptables代替FireWall防火墙">
                CentOS 7下使用iptables代替FireWall防火墙 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.jpg"
                alt="Jason Bian" />
            
              <p class="site-author-name" itemprop="name">Jason Bian</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">86</span>
                    <span class="site-state-item-name">posts</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">41</span>
                    <span class="site-state-item-name">categories</span>
                  
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">109</span>
                    <span class="site-state-item-name">tags</span>
                  
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#安装vsftpd"><span class="nav-number">1.</span> <span class="nav-text">安装vsftpd</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#基于虚拟用户配置ftp服务器"><span class="nav-number">2.</span> <span class="nav-text">基于虚拟用户配置ftp服务器</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#打开配置文件并修改"><span class="nav-number">2.1.</span> <span class="nav-text">打开配置文件并修改</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#对虚拟用户进行认证"><span class="nav-number">2.2.</span> <span class="nav-text">对虚拟用户进行认证</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#另参考"><span class="nav-number">3.</span> <span class="nav-text">另参考</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#有坑提示"><span class="nav-number">4.</span> <span class="nav-text">有坑提示</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jason Bian</span>

  

  
</div>




  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme – <a class="theme-link" target="_blank" href="https://theme-next.org">NexT.Gemini</a></div>




        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.4.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.4.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.4.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.4.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.4.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.4.0"></script>



  



  










  





  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
